Skip to content

fix(runtime): type runtime context and confirm summarization invariant (#2687)#2779

Draft
ShenAC-SAC wants to merge 3 commits intobytedance:mainfrom
ShenAC-SAC:fix/2687-runtime-context-summarization
Draft

fix(runtime): type runtime context and confirm summarization invariant (#2687)#2779
ShenAC-SAC wants to merge 3 commits intobytedance:mainfrom
ShenAC-SAC:fix/2687-runtime-context-summarization

Conversation

@ShenAC-SAC
Copy link
Copy Markdown
Contributor

@ShenAC-SAC ShenAC-SAC commented May 8, 2026

addresses #2687 item 5 and item 6

Draft sequencing note: this PR is intended to be finalized after #2769 (items 1/3/4) and #2778 (item 2) land, then rebased onto that updated main. The implementation and audit below describe the post-merge target shape, not a compatibility layer for multiple intermediate states.

Summary

  • worker.py: introduce a typed DeerFlowRuntimeContext, annotate runtime helpers, keep the runtime cast with the [refactor] follow-ups deferred from #2666 (app_config threading) #2687 TODO marker.
  • task_tool.py: read runtime app config through the new typed runtime context instead of an untyped cast.
  • agent.py: require middleware construction to receive app_config explicitly, removing the ambient get_app_config() fallback from both _build_middlewares and _create_summarization_middleware.
  • client.py: thread DeerFlowClient's preloaded self._app_config into _build_middlewares for the embedded-client path.
  • tests: cover explicit summarization config threading, bare helper rejection, and embedded-client middleware config propagation.

Invariant Audit (item 6)

This audit follows the config-threading direction established by the preceding #2687 PRs: config should be resolved at composition roots and then passed explicitly through runtime/middleware construction.

  • _build_middlewares: now requires app_config explicitly and passes it to _create_summarization_middleware — safe.
  • make_lead_agent_make_lead_agent: passes resolved_app_config explicitly to _build_middlewares — safe.
  • DeerFlowClient._ensure_agent: DeerFlowClient.__init__ preloads config, and _ensure_agent now passes self._app_config into _build_middlewares — safe.
  • Direct test invocations: previously omitted app_config; those tests now pass an explicit AppConfig or assert the bare helper call is invalid.

Verdict: the explicit-config invariant is enforced in the target post-#2769/#2778 state. Summarization middleware construction has a single config path, matching item 2's removal of duplicate config sources instead of preserving ambient fallbacks.

File Summary

  • worker.py: typed runtime context helpers and documented cast boundary.
  • task_tool.py: typed access to runtime config.
  • agent.py: single explicit app_config path for middleware construction.
  • client.py: embedded client passes its preloaded app config into middleware construction.
  • test_lead_agent_model_resolution.py / test_client.py: regression coverage for explicit config threading and no bare helper calls.

Merge Plan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant